<template>
  <div class="three">
    <dv-scroll-board
      @click="handleClick"
      v-if="config.data.length > 0"
      :config="config"
      style="width: 100%; height: 100%"
      class="table_arr"
    />

    <el-dialog
      title="验收详情"
      v-model="schoolOpen.open"
      width="900px"
      append-to-body
    >
      <el-table :data="tableData" border >
        <el-table-column prop="title" label="种类" />
        <el-table-column prop="num" label="验收数量" />
        <!-- <el-table-column prop="address" label="Address" /> -->
      </el-table>
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="schoolOpen.open = false">关闭</el-button>
          <!-- <el-button type="primary" @click="submitFileForm">确 定</el-button> -->
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import { selectCheckDay } from "@/api/progress";
import { school } from "./data";
import { onMounted, ref } from "vue";
import * as echarts from "echarts";
const schoolOpen = ref({
  open: false,
  arr: [],
});
const isShow = ref(false);
const config = ref({
  header: ["学校名称", "验收类型", "是否通过"],
  
  align:['center','center','center'],
  data: [
    // ['伊庄实小卫星厨房', '是'],
    // ['棠张小学卫星厨房', '是'],
    // ['大彭小学卫星厨房', '是'],
    // ['科技谷卫星厨房', '是'],
    // ['大学路北校区卫星厨房', '是'],
    // ['汉王镇刘庄小学卫星厨房', '是'],
    // ['利国镇磊庄卫星厨房', '是'],
    // ['大许河西卫星厨房', '是'],
    // ['茅村镇任庄卫星厨房', '是'],
    // ['何桥镇金寨路卫星厨房', '是'],
    // ['三堡实验小学卫星厨房', '是'],
    // ['新区实验小学卫星厨房', '是'],
    // ['马坡王堂幼儿园卫星厨房', '是'],
  ],
});

const tableData = ref([])

function handleClick(row) {
  // console.log("handleClick", );
  // if(row.rowIndex!= undefined){
  //   tableData.value = school.value[row.rowIndex].arr
  // }
  
  // schoolOpen.value.arr = row
  // schoolOpen.value.open = true;
}

function updateData(data) {
  // console.log('schoolschoolschool');
  // console.log(data);
  // console.log(e);
  // console.log(index);
  let arr = []
  
  selectCheckDay({ week: data.week }).then((res) => {
    if (res.code == 200) {
      // const now = new Date();
      // const hours = now.getHours();
      res.data.forEach((item) => {
        arr.push([item.schoolName, item.checkCate, '通过']);
      });
  config.value.data = arr;
    }
  });
  // console
  //   config.value.data = data
  isShow.value = true;
}

defineExpose({
  updateData,
});
</script>

<style lang='scss' scoped>
.table_arr {
  width: 100%;
  height: 100%;
}
.three {
  width: 95%;
  height: 90%;
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  right: 0;
  margin: auto;
}

.chart-wrapper {
  display: flex;
  justify-content: flex-end;
  width: 100%;
  height: 100%;
}

.chart-container {
  width: 100%;
  height: 100%;
}
</style>
